<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="auto">
      <el-form-item label="SN码:" prop="snCode">
        <el-input v-model="queryParams.snCode" placeholder="请输入SN码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="录入人:" prop="createBy">
        <el-input v-model="queryParams.createBy" placeholder="请输入录入人" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="修改人:" prop="updateBy">
        <el-input v-model="queryParams.updateBy" placeholder="请输入修改人" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['data:collect:historyProd:export']">导出</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="productList" height="calc(100vh - 240px)">
      <el-table-column type="index" label="序号" align="center" width="50" />
      <el-table-column label="客户名称" align="center" prop="customerName" />
      <el-table-column label="站点名称" align="center" prop="siteName" />
      <el-table-column label="站点地址" align="center" prop="siteAddress" />
      <el-table-column label="站点负责人" align="center" prop="siteManager" />
      <el-table-column label="联系方式" align="center" prop="contactInformation" />
      <el-table-column label="场站类型" align="center" prop="yardType" />
      <el-table-column label="站内充电桩数量" align="center" prop="quantity" />
      <el-table-column label="模块" align="center" prop="module" />
      <el-table-column label="模块规格" align="center" prop="moduleSpec" />
      <el-table-column label="屏幕" align="center" prop="screen" />
      <el-table-column label="屏幕规格" align="center" prop="screenSpec" />
      <el-table-column label="后台" align="center" prop="backstage" />
      <el-table-column label="巡检时间" align="center" prop="inspectionTime" />
      <el-table-column label="软件版本" align="center" prop="softwareVersion">
        <template slot-scope="scope">
          <el-image v-for="(item, index) in scope.row.softwareVersion" :key="index" :src="item" ref="previewImgVer" :preview-src-list="scope.row.softwareVersion" fit="fill"></el-image>
          <span class="el-upload-list__item-preview" @click="handlePictureCardPreviewVer()">
          </span>
        </template>
      </el-table-column>
      <el-table-column label="SN码" align="center" prop="snCode" />
      <el-table-column label="sn码图片" align="center" prop="snCodePhotograph">
        <template slot-scope="scope">
          <el-image v-for="(item, index) in scope.row.snCodePhotograph" :key="index" :src="item" ref="previewImgSN" :preview-src-list="scope.row.snCodePhotograph" fit="fill"></el-image>
          <span class="el-upload-list__item-preview" @click="handlePictureCardPreviewSN()">
          </span>
        </template>
      </el-table-column>
      <el-table-column label="ZN码/资产码" align="center" prop="znCode" />
      <el-table-column label="ZN码照片" align="center" prop="znCodePhotograph">
        <template slot-scope="scope">
          <el-image v-for="(item, index) in scope.row.znCodePhotograph" :key="index" :src="item" ref="previewImgZN" :preview-src-list="scope.row.znCodePhotograph" fit="fill"></el-image>
          <span class="el-upload-list__item-preview" @click="handlePictureCardPreviewZN()">
          </span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="录入人" align="center" prop="createBy" />
      <el-table-column label="修改人" align="center" prop="updateBy" />
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" :page-sizes="[10, 50, 150, 500]" @pagination="getList" />

  </div>
</template>

<script>
import {
  getHisdata,
} from "@/api/system/product";
export default {
  name: "QueryData",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        snCode: null,
        createBy: null,
        updateBy: null,
      },
      // 【历史产品数据收集】表格数据
      productList: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      getHisdata(this.queryParams).then(response => {
        console.log(response, '查询的res');
        if (response.code == 200) {
          this.productList = response.rows;
          this.total = response.total;
          this.loading = false;
        } else {
          this.msgError(response.msg);
        }
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //ZN图片预览
    handlePictureCardPreviewZN() {
      console.log("row");
      // 重点
      this.$refs.previewImgZN.showViewer = true
    },
    //SN图片预览
    handlePictureCardPreviewSN() {
      this.$refs.previewImgSN.showViewer = true
    },
    //软件版本
    handlePictureCardPreviewVer() {
      this.$refs.previewImgVer.showViewer = true
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('mes/pro/historical/info/export', {
        ...this.queryParams
      }, `info_${new Date().getTime()}.xlsx`)
    }
  },
};
</script>
